import axios from '@/utils/request'
export default {
  AttendanceLog: {
    list: {
      disabled_actions: ['new', 'lines'],
      query: {
        '@order': 'entity.id|DESC'
      },
      list_filter: {
        'store.id': () => {
          return axios
            .get(`/manage/stores`)
            .then(res =>
              Object.assign({ __label: '门店' },
                ...res.data.map(v => { return { [v.id]: v.name } })))
        },
        beforeCreatedTime: {
          expression: 'entity.getCreatedTime() >= datetime.get(":value 00:00:00")',
          label: '创建开始时间',
          type: 'date'
        },
        afterCreatedTime: {
          expression: 'entity.getCreatedTime() <= datetime.get(":value 23:59:59")',
          label: '创建结束时间',
          type: 'date'
        },
        date: {
          expression: 'entity.getDate() >= datetime.get(":value 00:00:00") && entity.getDate() <= datetime.get(":value 23:59:59")',
          label: '营业日期',
          type: 'date'
        }
      },
      list_display: [
        'id',
        'store',
        'staff',
        { property: 'type', label: '班次' },
        {
          property: 'phase',
          label: '上落班',
          component: {
            props: ['data'],
            render(h) {
              if (this.data) {
                return <span>上班</span>
              } else {
                return <span>落班</span>
              }
            }
          }
        },
        {
          property: 'date',
          label: '营业日期'
        },
        'createdTime'
      ]
    },
    form: {
      fields: [
        'id'
      ]
    }
  }
}

